var draw = {
		
		lineObject: new Array(),
		starPic:appCtx+"resources/images/mapTool/start.png",
		endPic:appCtx+"resources/images/mapTool/end.png",
		pointMarker:null,
		pointInfoMarker:null,
		imageMarkerList:new Array(),
		markList:new Array(),
		reset:function(){
			draw.lineObject = new Array();
			draw.pointInfoMarker=null;
			draw.imageMarkerList=new Array();
			draw.markList=new Array();
		},
		setCenter:function(lon,lat){
			 mapTool.map.setCenter([lon,lat]);
		},
		closeInfoWindow:function() {
		    mapTool.map.clearInfoWindow();
		},
		cleanAll:function(map){
			if(null!=draw.pointMarker){
				map.remove(draw.pointMarker);
				map.remove(draw.pointInfoMarker);
			}
			if(null!=draw.imageMarkerList){
				map.remove(draw.imageMarkerList);
			}
		},
		drawImage:function(imageList,map){
			draw.cleanAll(map);
			if(null!=imageList && imageList!=""){
				map.setZoom(13);				
				for(var i=0;i<imageList.length;i++){
					if(i==0){
						map.setCenter([imageList[i].gdLng,imageList[i].gdLat]);
					}
					var marker = new AMap.Marker({
				        map: map,
				        position: [imageList[i].gdLng,imageList[i].gdLat],
				        icon:appCtx+ "resources/images/mapTool/camera.png",
				    });
					var infoWindow = new AMap.InfoWindow({isCustom: true,offset: new AMap.Pixel(0, -10)}); 
					marker.content = "<div style='padding:15px;border:1px solid #dedede;background:#fff;position:relative;'>" +
							"<a  onclick='draw.closeInfoWindow()' style='position:absolute;top:3px;right:3px;background:url(" +
							"http://webapi.amap.com/images/close2.gif) 0 0 no-repeat;width:10px;height:10px;' href='javascript:;'></a>" +
							"<img class='db' style='height:200px;weight:300px;' src='"+imageList[i].imgUrl+"'>" +
									"<p style='padding-top:15px;'>拍照时间："+imageList[i].gpsTimeStr+"</p></div>";
					marker.on('click', function(e){
						 isopenWin=true;
						 infoWindow.setContent(e.target.content);
					     infoWindow.open(map, e.target.getPosition());			   	 
					});
					draw.imageMarkerList.push(marker);
					draw.imageMarkerList.push(infoWindow);
				}
			}
		},
		/**
		 * 画对应轨迹的地图标注
		 * 
		 * @param track
		 */
		drawPointMark:function(track){
			draw.cleanAll(mapTool.map);
			mapTool.map.setCenter(new AMap.LngLat(track.longitude, track.latitude));
			draw.pointMarker = new AMap.Marker({
    	        map:mapTool.map,
    	        position: [track.longitude, track.latitude],
    	        //icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png"
    	        icon: appCtx + 'resources/images/mapTool/home_icon_location.png'
    	    });
			draw.pointInfoMarker = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)}); 
    		draw.pointMarker.content = '定位时间：'+track.gps_time+'</br>速度：'+track.gps_speed+' 公里/小时</br>里程：'+(parseFloat(track.gps_mileage)/10).toFixed(1)+' 公里';
    		draw.pointMarker.on('click', function(e){
    			 isopenWin=true;
    			 draw.pointInfoMarker.setContent(e.target.content);
    			 draw.pointInfoMarker.open(mapTool.map, e.target.getPosition());    		   	 
    		});
    		draw.pointInfoMarker.open(mapTool.map, new AMap.LngLat(track.longitude, track.latitude));    		  
		},
		/**
		 * 画点，有弹出窗
		 * 
		 * @param track
		 */
		showPoint:function(track){
			draw.drawPointMark(track);
		},
		/**
		 * 画轨迹线
		    {
		    map
			lineArr
			carPic
			trackColor
			passTrackColor
			lineSize
		    }
		 * @param options
		 */
		drawTrackLine:function(options){
			if(null!=draw.markList){
				options.map.remove(draw.markList);
				draw.lineObject.lineArr = null;
				draw.lineObject.marker= null;
			}
			isPlay = false;
			draw.cleanAll(options.map);
			options.map.setZoom(13);
			// set map center
			mapTool.map.setCenter(options.lineArr[0]);
			// 车辆marker
			var marker = new AMap.Marker({
		        map: options.map,
		        position: options.lineArr[0],
		        icon: options.carPic,
		        offset: new AMap.Pixel(-26, -13),
		        autoRotation: true
		    });
			// 开始marker
			var startMarker = new AMap.Marker({
		        map: options.map,
		        position: options.lineArr[0],
		        icon: draw.starPic,
		        offset: new AMap.Pixel(-15, -30)
		    });
			// 结束marker
		    var endMarker = new AMap.Marker({
		        map: options.map,
		        position: options.lineArr[options.lineArr.length-1],
		        icon: draw.endPic,
		        offset: new AMap.Pixel(-15, -30)
		    });
		    // 绘制轨迹
		    var polyline = new AMap.Polyline({
		        map: options.map,
		        path: options.lineArr,
		        strokeColor: options.trackColor,  //线颜色
		        strokeWeight: options.lineSize,      //线宽
		    });
		    // 绘制已经播放过的线
		    var passedPolyline = new AMap.Polyline({
		        map: options.map,
		        strokeColor: options.passTrackColor,  //线颜色
		        strokeWeight: options.lineSize,      //线宽
		    });
		    marker.on('moving',function(e){
		        passedPolyline.setPath(e.passedPath);
		    })
		    options.map.setFitView();
		    
		    draw.lineObject.lineArr = options.lineArr;
		    draw.lineObject.marker=marker;
		    draw.markList.push(marker);
		    draw.markList.push(startMarker);
		    draw.markList.push(endMarker);
		    draw.markList.push(polyline);
		    draw.markList.push(passedPolyline);
		}
}

var tabUtils = {
		init:function(){
			this.tabInt = this.tab();
		},
		show:function(showIds,hidenIds,showTabIndex,updateTabName){
			tabUtils.tabInt.refash(showTabIndex);
			$("#tab_"+(showTabIndex)).html(updateTabName);
			for(var i=0;i<showIds.length;i++){
				$("#"+showIds[i]).show();
			}
			for(var i=0;i<hidenIds.length;i++){
				$("#"+hidenIds[i]).hide();
			}
		},
		/**
		 * tab页切换
		 */
		tab:function(){
			var index = 0;
			var func = function(){
				$('.trackTabTitle').find('.list').removeClass('active').eq(index).addClass('active');
				$('.trackTabCont').find('.list').hide().eq(index).show();
				$('.trackTab').find('.line').css({
					'left' : 100 * index + 'px'
				});
			};
			$('.trackTabTitle').find('.list').click(function(){
				index = $(this).index();
				func();
			});
			return {
				index : index,
				refash : function(i){			//外部点击时调用
					index = i;
					func();
				}
			};
		}
}
tabUtils.init();
/**
 * 轨迹查询业务
 */
var trackQuery = {
		
		allTrackList:null,
		alarmTrackList:null,
		currentTrackList:null,
		trackSplitPageIndex:0,//所有轨迹的分页
		alarmTrackSplitPageIndex:0,//报警轨迹的分页
		pageSize:500,
		
		reset:function(){
			trackQuery.allTrackList = null;
			trackQuery.alarmTrackList=null;
			trackQuery.currentTrackList=null;
			trackQuery.trackSplitPageIndex=0;
		},
		/**
		 * 查询报警路段的轨迹数据
		 * 
		 * @param obj
		 */
		showAlarmTrack:function(obj,type){
			
			if(0==type){
				$("#alarmDetailList2").hide();
				$("#trackList").show();
				$("#li_tab_2").show();
				$("#tab_2").html("报警段轨迹详情");
				trackSubSectin.tabInt.refash(2);
				trackQuery.queryTrack(obj.vehicleid,obj.startdatetime,obj.enddatetime,"trackTable");
			}else{
				$("#alarmTrackList").show();
				$("#li_tab_3").show();
				$("#tab_3").html("报警段轨迹详情");
				trackSubSectin.tabInt.refash(3);
				trackQuery.queryTrack(obj.vehicleid,obj.startdatetime,obj.enddatetime,"alarmTrackTable");
			}
		},		
		
		/**
		 * 查询报警路段的轨迹数据
		 * 
		 * @param obj
		 */
		showSubDetailTrack:function(vehicle_id,start_time,end_time,tbId){
			$("#alarmDetailList2").hide();
			$("#trackList").show();
			$("#li_tab_2").show();
			$("#tab_2").html("分段轨迹详情");
			trackSubSectin.tabInt.refash(2);
			trackQuery.queryTrack(vehicle_id,start_time,end_time,tbId);
		},	
		/**
		 * 画轨迹线
		 * 
		 * @param trackList
		 */
		showTrackSpeedLine:function(trackList,options){
			isPlay = false;
			var lonlatArr = new Array();
			speedList = new Array();
			dateList = new Array();
			trackInfoArray = [];
			for(var i=0;i<trackList.length;i++){
				speedList[i]=trackList[i].gps_speed;
				dateList[i]=trackList[i].gps_time;
				trackInfoArray[i]=trackList[i];
				lonlatArr.push([trackList[i].longitude,trackList[i].latitude]);	
    		}	
			charUtil.echart(speedList,dateList);
			draw.drawTrackLine({
			    	"map":mapTool.map,"lineArr":lonlatArr,"carPic":appCtx+"resources/images/mapTool/car1.png",
		    		"trackColor":options.color1,"passTrackColor":options.color2,"lineSize":options.lineSize
	    	});			
		},
		/**
		 * 查询所有轨迹，进入页面初始化的时候查询
		 * 
		 * @param vid 车牌号码
		 * @param star 开始时间
		 * @param end 结束时间
		 */
		queryAllTrack:function(vid,star,end){
			trackQuery.allTrackList = null;
			 $.ajax({
				 	url:appCtx+"gis/playback/queryListOps.jhtml",
				 	data:{"vehicleId":vid,"starDate":star,"endDate":end,"merge_seconds":-1,"stop_seconds":-1},
					dataType : "JSON",
		            success : function(data){
		                if(data){
		                	trackQuery.allTrackList=data.rows;
		                	trackQuery.showTrackSpeedLine(trackQuery.allTrackList,{"color1":"#00A","color2":"#F00","lineSize":5});
		                }
		                global.ajaxLoading.close();
		            }
			 });
		},
		///==================内存轨迹数据及分页===============================///////
		/**
		 * 从内容load更多轨迹数据，按内存分页条数展示
		 */
		moreTrackList:function(tbId){
			var count = 0;
			for(var i=trackQuery.trackSplitPageIndex;i<trackQuery.currentTrackList.length;i++){
				trackQuery.trackSplitPageIndex=i;
				count++;
				$("#"+tbId).append(trackQuery.trackTrHtml(trackQuery.currentTrackList[i],i));
				if(count>=trackQuery.pageSize){
					trackQuery.trackSplitPageIndex=i+1;
					break;
				}
			}
			if(trackQuery.currentTrackList.length==(trackQuery.trackSplitPageIndex+1)){
				if(tbId=="trackTable"){
					$("#moreRows").hide();
				}else{
					$("#moreRows2").hide();
				}				
			}
		},
		/**
		 * 从内容load轨迹数据，按内存分页条数展示
		 */
		showAllTrackOneDay:function(){
			exportStartTime=$("#startTime").val()+" 00:00:00";
			exportEndTime=$("#endTime").val()+" 23:59:59";
			exportVehicleID=$("#selectVehicleSel").val();
			trackQuery.currentTrackList = trackQuery.allTrackList;//当前轨迹
			trackQuery.showTrackSpeedLine(trackQuery.allTrackList,{"color1":"#00A","color2":"#F00","lineSize":5});
			tabUtils.show(["trackList","li_tab_2"],["alarmDetailList2"],2,"轨迹详情");
			trackQuery.showFirstPageTrack("trackTable");
		},
		showFirstPageTrack:function(tbId){
			trackQuery.trackSplitPageIndex = 0;
			$("#"+tbId+" tr:not(:first)").remove();
			if(trackQuery.currentTrackList.length<=trackQuery.pageSize){
				if(tbId=="trackTable"){
					$("#moreRows").hide();
				}else{
					$("#moreRows2").hide();
				}				
			}else{
				if(tbId=="trackTable"){
					$("#moreRows").show();
				}else{
					$("#moreRows2").show();
				}				
			}
			for(var i=0;i<trackQuery.currentTrackList.length;i++){
				$("#"+tbId).append(trackQuery.trackTrHtml(trackQuery.currentTrackList[i],i));
				if(i>=(trackQuery.pageSize-1)){
					trackQuery.trackSplitPageIndex=i+1;
					break;
				}
			}
		},
		/**
		 * 轨迹拼装HTML 行
		 * @param track
		 * @param rowNumber
		 * @returns {String}
		 */
		trackTrHtml:function(track,rowNumber){
			var _class = "trackRow";
			if(rowNumber%2==0) _class = ""; else _class = "trackRow";
			return "<tr class="+_class+" onclick='draw.showPoint("+ JSON.stringify(track)+")'><td>"+(rowNumber+1)+"</td><td>"+track.gps_time+"</td><td>"+track.longitude+"</td><td>"+track.latitude+"</td><td>"+track.gps_speed+"</td><td>"+track.gps_mileage/10+"</td><td>"+track.status+"</td></tr>";
		},
		///==================内存轨迹数据及分页===============================///////
		
		/**
		 * 轨迹查询
		 * 
		 * @param vid
		 * @param star
		 * @param end
		 */
		queryTrack:function(vid,star,end,tbId){
			exportStartTime=star;
			exportEndTime=end;
			exportVehicleID=vid;
			 $.ajax({
				 	url:appCtx+"gis/playback/queryListOps.jhtml",
				 	data:{"vehicleId":vid,"starDate":star,"endDate":end,"merge_seconds":-1,"stop_seconds":-1},
					dataType : "JSON",
		            success : function(data){
		                if(data){
		                	trackQuery.alarmTrackList = data.rows;
		                	trackQuery.currentTrackList = trackQuery.alarmTrackList ;//当前轨迹
		                	trackQuery.showTrackSpeedLine(data.rows,{"color1":"#AE0000","color2":"#F00","lineSize":5});
		                	trackQuery.showFirstPageTrack(tbId);
		                }
		            }
			 });
		}
}
var charUtil = {
		/**
		 * echart
		 * */
		echart : function(speedList,timeList){
			var option = {
					tooltip : {
				        trigger: 'axis',
				        formatter: function (params) {
				            params = params[0];
				            return "时间:"+params.name+"<br/>"+"速度:"+params.value;
				        },
				        axisPointer: {
				        	animation: false
				        }
				    },
				    grid: {
				        left: '3%',
				        right: '3%',
				        top: '5%',
				        bottom:0,
				        containLabel: true
				    },
				    xAxis : [
				        {
				            type : 'category',
				            boundaryGap : false,
				            data :timeList
				        }
				    ],
				    yAxis : [
				        {
				            type : 'value'
				        }
				    ],
				    series : [
				        {
				            name:'速度',
				            type:'line',
				            smooth:true,
				            data:speedList
				        }
				    ]
			};
			
			
			$('#monitorCharts').html('');
			var myChart = echarts.init(document.getElementById('monitorCharts'));
	        myChart.setOption(option);
//	        myChart.on('click', function (params) {
//	            console.log(params);
//	        });
	        myChart.on("click", eConsole);
	        
	        
	        return {
	        	option : option,
	        	chartDrivingDom : myChart
	        };
		}
}

/**
 * 
 */
var trackSubSectin = {
		runList :new Array(),
    	stopList:new Array(),
    	allSubList:new Array(),
    	
		reset:function(){
			trackSubSectin.runList = new Array();
			trackSubSectin.stopList=new Array();
			trackSubSectin.allSubList=new Array();
		},
		
    	clickQuery:function(){
    		var vid=$("#selectVehicleSel").val();
    		var starTime = $("#startTime").val();
    		var endTime = $("#endTime").val();
    		starTime = starTime+" 00:00:00";
    		endTime=endTime+" 23:59:59";
    		var end_str = (endTime).replace(/-/g,"/");//一般得到的时间的格式都是：yyyy-MM-dd hh24:mi:ss，所以我就用了这个做例子，是/的格式，就不用replace了。  
    		var end_date = new Date(end_str);//将字符串转化为时间  
    		//开始时间  
    		var sta_str = (starTime).replace(/-/g,"/");  
    		var sta_date = new Date(sta_str);  
    		var num = (end_date-sta_date)/(1000*3600*24);//求出两个时间的时间差，这个是天数  
    		var days = parseInt(Math.ceil(num));//转化为整天（小于零的话剧不用转了） 
    		if(days>3){
    			global.ajaxLoading.pop("查询时间不能超过三天",false,2000);
    			return;
    		}
    		if(days<0){
    			global.ajaxLoading.pop("开始时间必须小于结束时间",false,2000);
    			return;
    		}
    		if(vid!=""){
    			trackSubSectin.querySubSection(vid,starTime,endTime);
    			trackSubSectin.initSubDetail();    			
    		}else{
    			global.ajaxLoading.pop("请选择车辆",false,2000);
    		}
    	},
    	queryByCondition:function(){
    		var vid=$("#vid").val();
    		var starTime = $("#startTime").val();
    		var endTime = $("#endTime").val();
    		starTime = starTime+" 00:00:00";
    		endTime=endTime+" 23:59:59";
    		if(vid!=""){
    			trackSubSectin.querySubSection(vid,starTime,endTime);
    			trackSubSectin.initSubDetail();
    		}
    	},
    	loadVehicle:function(){
    		var vid = $("#vid").val();
    		var regNo = $("#regNo").val();
    		
    		$('#selectVehicleSel').html("<option value='"+vid+"' selected='selected'>"+regNo+"</option>");
    		$('#selectVehicleSel').attr("disabled","disabled");
    		
			/*$.ajax({
				   	type : 'post',
				   	async : false,
				   	url : appCtx + "/system/vehicle/loadUserVehicle.html",
				   	cache : false,
				   	dataType : "JSON",
				   	success : function(data) {			
				    	if(data){
				    		var selectStr="";
		    				selectStr+="<option value=''>请选择</option>";
		    				$.each(data.vehicleList,function(entryIndex,entry) {
		    					selectStr+="<option value='"+entry.vehicleId+"'>"+entry.registrationNO+"</option>";
		    				});
		    				var vid=$("#vid").val();
		    				$('#selectVehicleSel').html(selectStr);
		    				if(vid!=null && vid!=undefined){
		    					$("#selectVehicleSel").val(vid);	
		    				}		    				
		    				$("#selectVehicleSel").select2();
				    		trackSubSectin.queryByCondition();
				    	}
				   	}
			   });*/
    	},
		init:function(){
			this.domH();
			charUtil.echart([],[]);
			this.loadVehicle();
			this.tabInt = this.tab();			
		},showSaveTrackLine:function(vehicle_id,start_time,end_time,start_lon,start_lat,end_lon,end_lat,mileage){
			curTrackLineM=mileage;
			if(start_lon=='0' || start_lat=='0'){
				startPositionTrackLine="";
			}else{
				var address = mapTool.initHashMap.GlobalAddressCache.get(start_lon+'_'+start_lat);
				if(address){
					startPositionTrackLine= address;
				}else{
					var geocoder = new AMap.Geocoder({
			            radius: 1000,
			            extensions: "all"
			        });        
			        geocoder.getAddress(new AMap.LngLat(start_lon, start_lat), function(status, result) {
			            if (status === 'complete' && result.info === 'OK') {
			            	var address=result.regeocode.formattedAddress;
			            	mapTool.initHashMap.GlobalAddressCache.put(start_lon+'_'+start_lat);
			            	startPositionTrackLine= address;
			            }
			        });     
				}	    
			}
			
			if(end_lon=='0' || end_lat=='0'){
				endPositionTrackLine="";
			}else{
				var address = mapTool.initHashMap.GlobalAddressCache.get(end_lon+'_'+end_lat);
				if(address){
					endPositionTrackLine= address;
				}else{
					var geocoder = new AMap.Geocoder({
			            radius: 1000,
			            extensions: "all"
			        });        
			        geocoder.getAddress(new AMap.LngLat(end_lon, end_lat), function(status, result) {
			            if (status === 'complete' && result.info === 'OK') {
			            	var address=result.regeocode.formattedAddress;
			            	mapTool.initHashMap.GlobalAddressCache.put(end_lon+'_'+end_lat);
			            	endPositionTrackLine= address;
			            }
			        });     
				}	    
			}
			
			vehicleIDTrackLIne=vehicle_id;
		    startTimeTrackLIne=start_time;
		    endTimeTrackLIne=end_time;
			$('#trackLinePop').modal('show');
		},
		initSubDetail:function(){
			var _this = this;
			var showHisVideo=function(vid){
				return "<a href="+appCtx+"video/hisVideo.html?vehicleID="+vid+" target='blank'>视频回放</a>";
			};
			var showAddress=function(address,lon,lat){
				if(address==null || address==""){
					return "<a onclick=\"mapUtils.getAddress(this,"+lon+","+lat+");\">查看</a>";	
				}else{
					return  address;
				}
			};
			var saveTrackLine=function(vehicle_id,start_time,end_time,analyse_falg,start_lon,start_lat,end_lon,end_lat,mileage){
				if(analyse_falg==1){
					return "<a  onclick=\"trackSubSectin.showSaveTrackLine('"+vehicle_id+"','"+start_time+"','"+end_time+"','"+start_lon+"','"+start_lat+"','"+end_lon+"','"+end_lat+"','"+mileage+"')\"><font color=blue>保存</font></a>";	
				}else{
					return "<a ><font color=gray>保存</font></a>";	
				}
				
			};
			
			var queryTrackDetailInfo=function(vehicle_id,start_time,end_time){

				return "<a  onclick=\"trackQuery.showSubDetailTrack('"+vehicle_id+"','"+start_time+"','"+end_time+"','trackTable')\"><font color=blue>查看</font></a>";	
			};
			
			var formatMileages=function(mileage){
				return  parseFloat(mileage).toFixed(1);
			}
			
			$("#monitorList").flexigrid({
				dataType: 'json',
	            colModel : [
	                  {
	                display : '详细轨迹',
	                name : 'trackDetailInfo',
	                width : 90,
	                sortable : false,
	                align : 'left',
	                className:'cursor',
	                paramcolnames : ['vehicle_id','start_time','end_time'],
	                handlefunction:queryTrackDetailInfo
	                 } ,{
	        	       display : 'VID',
	        	      name : 'vehicle_id',
	        	      hide:true,
	        	      sortable : false,
	        	      align : 'left',
	        	     },
	            	{
	                display : '总里程(km)',
	                name : 'mileage',
	                width : 80,
	                sortable : false,
	                align : 'left',
	                paramcolnames : ['mileage'],
	                handlefunction:formatMileages
	            },{
	                display : '开/停车时长',
	                name : 'duration_time',
	                width : 80,
	                sortable : false,
	                align : 'left',
	            },{
	                display : '开始时间',
	                name : 'start_time',
	                width : 150,
	                sortable : false,
	                align : 'left',
	            },{
	                display : '结束时间',
	                name : 'end_time',
	                width : 150,
	                sortable : false,
	                align : 'left',
	            },	          
	            {
	                display : '超速',
	                name : 'speed_alarm',
	                width : 60,
	                sortable : false,
	                align : 'left',
	                className:'cursor'
	            }
	            ,{
	                display : '道路类型超速',
	                name : 'road_level_speed_alarm_count',
	                width : 150,
	                sortable : false,
	                align : 'left',
	                className:'cursor'
	            },
	            {
	                display : '夜间行车',
	                name : 'vehicle_night_alarm',
	                width : 60,
	                sortable : false,
	                align : 'left',
	                className:'cursor'
	            }
	            ,
	            {
	                display : '疲劳驾驶',
	                name : 'tired_alarm',
	                width : 60,
	                sortable : false,
	                align : 'left',
	                className:'cursor'
	            },	   
	            {
	                display : '图片',
	                name : 'image_count',
	                width : 50,
	                sortable : false,
	                align : 'left',
	                className:'cursor'
	            },
	            {
	                display : '开始地点',
	                name : 'startposition',
	                width : 150,
	                sortable : false,
	                align : 'left',
	                className:'cursor',
	                paramcolnames : ['startposition','start_lon','start_lat'],
	                handlefunction:showAddress
	            },{
	                display : '结束地点',
	                name : 'endposition',
	                width : 150,
	                sortable : false,
	                align : 'left',
	                className:'cursor',
	                paramcolnames : ['endposition','end_lon','end_lat'],
	                handlefunction:showAddress
	            },{
	                display : '保存线路',
	                name : 'saveTrackLine',
	                width : 90,
	                sortable : false,
	                align : 'left',
	                className:'cursor',
	                paramcolnames : ['vehicle_id','start_time','end_time','analyse_falg','start_lon','start_lat','end_lon','end_lat','mileage'],
	                handlefunction:saveTrackLine
	            }/*,{
	                display : '回放视频',
	                name : 'dealContent',
	                width : 110,
	                sortable : false,
	                align : 'left',
	                paramcolnames : ['vehicle_id'],
	                handlefunction:showHisVideo
	            }*/
	            ],
	            resizable : false,
	            sortname : "start_time",// 第一次加载数据时排序列
	            sortorder : "desc",// 第一次加载数据时排序类型
	            usepager : false,// 是否分页，默认为true。
	            showToggleBtn : false,
	            showTableToggleBtn : false,// 是否显示收起/打开按钮,默认不显示。
	            useRp : true,// 是否可以动态设置每页显示的结果数，默认为false。
	            rp : 10,// 每页记录数，默认为10
	            rpOptions: [10,50,100,300,500], // 每页结果数
	            checkbox : false,// 是否要多选框,默认为false。
	            singleSelect : true,
	            width : 'auto',// 表格宽度
	            height : _this.flexHeight, // 表格高度
	            titDisplay:false,
	            onSuccess : function(data){
	            },
	            onSelectRow : function(row,title){
	            	if(title==undefined){
	            		/*trackQuery.showSubDetailTrack(row,"trackTable");*/
	            	}else{
	            		if(title=="speed_alarm"){
	            			alarmDetail.querySpeed(row.speed_alarm,row.vehicle_id,row.start_time,row.end_time,1);	
	            		}
	            		if(title=="road_level_speed_alarm_count"){
	            			alarmDetail.queryRoadLevelSpeed(row.road_level_speed_alarm_count,row.vehicle_id,row.start_time,row.end_time,1);	
	            		}
	            		if(title=="vehicle_night_alarm"){
	            			alarmDetail.queryNightAlarm(row.vehicle_night_alarm,row.vehicle_id,row.start_time,row.end_time,1);	
	            		}
	            		if(title=="tired_alarm"){
	            			alarmDetail.queryTiredAlarm(row.tired_alarm,row.vehicle_id,row.start_time,row.end_time,1);	
	            		}
	            		if(title=="image_count"){
	            			alarmDetail.queryHisImage(row.image_count,row.vehicle_id,row.start_time,row.end_time,1);	
	            		}
	            	}	            
	            },
	            onSelectAllRow : function(data){
	            }
	        });
		},
		/**
		 * tab页切换
		 */
		tab : function(){
			var index = 0;
			var func = function(){
				$('.trackTabTitle').find('.list').removeClass('active').eq(index).addClass('active');
				$('.trackTabCont').find('.list').hide().eq(index).show();
				$('.trackTab').find('.line').css({
					'left' : 100 * index + 'px'
				});
			};
			$('.trackTabTitle').find('.list').click(function(){
				index = $(this).index();
				func();
			});
			return {
				index : index,
				refash : function(i){			//外部点击时调用
					index = i;
					func();
				}
			};
		},		
		closeQueryCondition:function(){
			$("#queryCondition").hide();
			$("#showQueryPanel").show();
		},
		openQueryCondition:function(){
			$("#queryCondition").show();
			$("#showQueryPanel").hide();
		},
		/**
		 * 各dom高度
		 * */
		domH : function(){
			var winH = $(window).height();
			$('#mymap').height(winH-330);
			this.flexHeight = 157;
		},
		subSectionRun:function(){
			runOrStopDuration=1;
			tabUtils.show(["monitorList"],["trackList","alarmDetailList","alarmDetailList2","alarmTrackList","li_tab_2","li_tab_3"],1,"行车时段");
			$(".flexigrid").eq(0).show();
			$(".hDivBox").find('thead tr:first').children('th').eq(3).children().html("开车时长");
			exportisRunStopStr="开车时长";
			$("#monitorList").flexAddData({"rows":trackSubSectin.runList});
		},
		subSectionStop:function(){
			runOrStopDuration=2;
			tabUtils.show(["monitorList"],["trackList","alarmDetailList","alarmDetailList2","alarmTrackList","li_tab_2","li_tab_3"],1,"停车时段");
			$(".flexigrid").eq(0).show();
			$(".hDivBox").find('thead tr:first').children('th').eq(3).children().html("停车时长");
			exportisRunStopStr="停车时长";
			$("#monitorList").flexAddData({"rows":trackSubSectin.stopList});
		},
		showAllSubList:function(){
			runOrStopDuration=0;
			$(".flexigrid").eq(0).show();
			tabUtils.show(["monitorList"],["li_tab_2","alarmDetailList","alarmDetailList2"],1,"分段轨迹");
			$(".hDivBox").find('thead tr:first').children('th').eq(3).children().html("开/停车时长");
			exportisRunStopStr="开/停车时长";
        	$("#monitorList").flexAddData({"rows":""});
        	$("#monitorList").flexAddData({"rows":trackSubSectin.allSubList});
		},
		querySubSection:function(vid,star,end){	
			
			/*try{
				$.ajax({
					type : 'post',
					async : true,
					data :[{
					     name : 'vehicleID',
					     value :vid
					     }],
					url : appCtx + "video/queryVideoVehicleIsOn.html",
					cache : false,
					dataType : "json",
					success : function(data) {
						if(data){
							if(data.length>0){
								isVideo=true;
							}else{
								isVideo=false;
							}
						}
					}
				});
			}catch(e){
				
			}*/
			
			$("#objTable tr:eq(1)").remove(); 
			$("#alarmTrackTable tr:not(:first)").remove();
			$("#trackTable tr:not(:first)").remove(); 
			$("#alarmDetailTable tr:not(:first)").remove();
			$("#alarmDetailTable2 tr:not(:first)").remove();
			$("#monitorList").flexAddData({"rows":""});
			$("#playControlBox").hide();
			charUtil.echart([],[]);
			mapTool.map.clearMap();
			draw.reset();
			trackQuery.reset();
			trackSubSectin.reset();
			tabUtils.show([],["trackList","monitorList","alarmDetailList","alarmDetailList2","alarmTrackList","li_tab_2","li_tab_3"],0,"轨迹汇总信息");
			var getTimestamp=new Date().getTime();
			global.ajaxLoading.pop('正在拼命加载,请稍候!',true);
			 $.ajax({
		            url : appCtx+'gis/playback/queryListSubsectionOps.jhtml?v='+getTimestamp,
		            data:{"vehicleId":vid,"startDate":star,"endDate":end},
		            dataType : "JSON",
		            success : function(result){		    
		                if(result && null!=result.subsectionVO){
		                	if(null!=result){
		                		setTimeout(function(){
		                			trackQuery.queryAllTrack(vid,star,end)
		                		},1000);
		                		$("#playControlBox").show();
		                		trackSubSectin.closeQueryCondition();
		                		var totalDuration = result.totalDuration;
			                	var runDuration = 0;
			                	var topDuration = 0;
			                	var subList = result.subsectionVOs;	
			                	var subVo = result.subsectionVO;	
			                	totalSubsection = result.subsectionVO;
			                	var stopCount=0;
			                	var runCount=0;
			                	$("#process_sub").html("");
			                	for(var i=0;i<subList.length;i++){
			                		var sub = subList[i];
			                		var currentDuration = parseInt((sub.duration/totalDuration)*100);
			                		if(sub.analyse_falg==0){//停车
			                			topDuration+=sub.duration;
			                			$("#process_sub").append("<div class=\"stop carBar\" style=\"width:"+currentDuration+"%;\"/>");
			                			trackSubSectin.stopList[stopCount]=sub;
			                			stopCount++;
			                		}else{//开车
			                			runDuration+=sub.duration;			                		
			                			$("#process_sub").append("<div class=\"start carBar\" style=\"width:"+currentDuration+"%;\"/>");
			                			trackSubSectin.runList[runCount]=sub;
			                			runCount++;
			                		}
			                	}
			                	if(runDuration/3600>=1){//超过一个小时
			                		var h=Math.floor(runDuration/(60*60)); 
			                		var m=Math.floor((runDuration%(60*60))/60%60); 
			                		var s=Math.floor((runDuration%(60)));
//			                		
//			                		var h = Math.round(runDuration/3600);
//			                		var m = Math.round(runDuration%3600/60);
			                		runDuration=h+"时"+m+"分"+s+"秒";
			                	}else{
			                		var m=Math.floor((runDuration%(60*60))/60%60); 
			                		var s=Math.floor((runDuration%(60)));
			                		
//			                		var m = Math.round(runDuration/60);
			                		runDuration=m+"分"+s+"秒";
			                	}
			                	if(topDuration/3600>=1){//超过一个小时
			                		var h=Math.floor(topDuration/(60*60)); 
			                		var m=Math.floor((topDuration%(60*60))/60%60); 
			                		var s=Math.floor((topDuration%(60)));
			                		
//			                		var h = Math.round(topDuration/3600);
//			                		var m = Math.round(topDuration%3600/60);
			                		topDuration=h+"时"+m+"分"+s+"秒";
			                	}else{
			                		var m=Math.floor((topDuration%(60*60))/60%60); 
			                		var s=Math.floor((topDuration%(60)));
			                		
//			                		var m = Math.round(topDuration/60);
			                		topDuration=m+"分"+s+"秒";
			                	}
			                	if(subVo.internalNo==undefined){
			                		subVo.internalNo="";
			                	}else{
			                		subVo.internalNo="("+subVo.internalNo+")";
			                	}
			                	totalTopDuration=topDuration;
			                	totalRunDuration=runDuration;
			                	var tr="";
			                	
			                	var videoStr="";
			                	if(isVideo){
			                		videoStr="<td style='cursor:pointer;color: blue;' ><a style='color: blue;' href="+appCtx+"video/hisVideo.html?vehicleID="+subVo.vehicle_id+" target='blank'>视频回放</a></td></tr>";
			                	}else{
			                		videoStr="<td style='cursor:pointer;color: gray;' ><a style='color: gray;' href='javascript:;'>视频回放</a></td></tr>";
			                	}
			                	if(isToday(star)){
			                		tr="<tr><td  style='cursor:pointer;color: blue;' title='点击查看所有分段' onclick='trackSubSectin.showAllSubList()'>"+subVo.registrationNo+subVo.internalNo+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看所有轨迹' onclick='trackQuery.showAllTrackOneDay()'>"+subVo.mileage+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看行驶分段' onclick='trackSubSectin.subSectionRun()'>"+runDuration+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看停车分段' onclick='trackSubSectin.subSectionStop()'>"+topDuration+"</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看超速详情' onclick='alarmDetail.querySpeed("+subVo.speed_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>-</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看道路类型超速详情' onclick='alarmDetail.queryRoadLevelSpeed("+subVo.road_level_speed_alarm_count+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>-</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看夜间行车详情' onclick='alarmDetail.queryNightAlarm("+subVo.vehicle_night_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>-</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看疲劳驾驶详情' onclick='alarmDetail.queryTiredAlarm("+subVo.tired_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>-</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看图片详情' onclick='alarmDetail.queryHisImage("+subVo.image_count+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.image_count+"</td>";
			                	}else{
			                		tr="<tr><td  style='cursor:pointer;color: blue;' title='点击查看所有分段' onclick='trackSubSectin.showAllSubList()'>"+subVo.registrationNo+subVo.internalNo+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看所有轨迹' onclick='trackQuery.showAllTrackOneDay()'>"+subVo.mileage+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看行驶分段' onclick='trackSubSectin.subSectionRun()'>"+runDuration+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看停车分段' onclick='trackSubSectin.subSectionStop()'>"+topDuration+"</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看超速详情' onclick='alarmDetail.querySpeed("+subVo.speed_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.speed_alarm+"</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看道路类型超速详情' onclick='alarmDetail.queryRoadLevelSpeed("+subVo.road_level_speed_alarm_count+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.road_level_speed_alarm_count+"</td>" +
		                	    	"<td style='cursor:pointer;color: blue;' title='点击查看夜间行车详情' onclick='alarmDetail.queryNightAlarm("+subVo.vehicle_night_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.vehicle_night_alarm+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看疲劳驾驶详情' onclick='alarmDetail.queryTiredAlarm("+subVo.tired_alarm+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.tired_alarm+"</td>" +
		                			"<td style='cursor:pointer;color: blue;' title='点击查看图片详情' onclick='alarmDetail.queryHisImage("+subVo.image_count+","+subVo.vehicle_id+",\""+subVo.start_time+"\",\""+subVo.end_time+"\",0)'>"+subVo.image_count+"</td>" ;
			                	}
			                	$("#objTable tr:eq(0)").after(tr); 
			                	trackSubSectin.allSubList = subList;
			                	$("#monitorList").flexAddData({"rows":subList});
			                	$("#monitorList").show();
					    		$(".flexigrid").eq(0).show();				
		                	}
		                }else{
		                	$("#objTable tr:eq(0)").after("<tr><td colspan='10'>无数据</td></tr>"); 
		                	global.ajaxLoading.pop("查询无结果",false,1500);
		                }
		            }
		        });
		}
}

var alarmDaily = {
		nightTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>行驶里程</th><th>行驶里程</th>",
		speedTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>累计时间</th><th>累计里程</th><th>最高速度</th><th>最低速度</th><th>平均速度</th></tr>",
		roadLevelSpeedTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>道路类型名称</th><th>超速时长</th><th>限速</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>超速里程</th><th>最高速度</th><th>最低速度</th><th>平均速度</th></tr>",
		tiredTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>开始疲劳时间</th><th>结束时间</th><th>累计时间</th><th>累计里程</th><th>开始地点</th><th>结束地点</th></tr>",
		// 显示报警
		showAlarm:function(tabName,tbHead,alarmList,showColumns){
			tabUtils.show(["alarmDetailList"],["trackList","monitorList","alarmDetailList2","alarmTrackList","li_tab_2","li_tab_3"],1,tabName);
			$(".flexigrid").eq(0).hide();
			$("#alarmDetailTable").html("");
			$("#alarmDetailTable").html(tbHead);
			if(null!=alarmList && alarmList!=""){
				var columnsSize = showColumns.length;
				var tr ="";
				exportAlarmListInfo=alarmList;
				for(var j=0;j<alarmList.length;j++){
					var alarmObj = alarmList[j];
					if(i%2==0 && tabName!="历史图片"){//onclick='trackQuery.showAlarmTrack("+ JSON.stringify(alarmObj)+",0)'
						tr+="<tr style=\"background-color: #F8F8FF;\"  >";
					}else if(tabName!="历史图片"){// onclick='trackQuery.showAlarmTrack("+ JSON.stringify(alarmObj)+",0)'
						tr+="<tr >";
					}else{
						tr+="<tr onclick='draw.setCenter("+ alarmObj.gdLng+","+alarmObj.gdLat+")'>";
					}
					
					for(var i=0;i<columnsSize;i++){
						if(showColumns[i].indexOf("startposition")>-1 || showColumns[i].indexOf("intPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.startlon+"','"+alarmObj.startlat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}
						}else if(showColumns[i].indexOf("endposition")>-1  || showColumns[i].indexOf("outPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.endlon+"','"+alarmObj.endlat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}							 
						}else if(showColumns[i].indexOf("picPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.gdLng+"','"+alarmObj.gdLat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}							 
						}else if (showColumns[i].indexOf("imgUrl")>-1){
							var imageUrl = alarmObj[showColumns[i]];
							tr+="<td><a style='cursor:pointer;'  onclick=\"alarmDaily.showImage('"+imageUrl+"')\">查看</a></td>";
						}else if(showColumns[i].indexOf("showDetailTrackInfo")>-1){
							
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\'trackQuery.showAlarmTrack("+JSON.stringify(alarmObj)+",0);\'>查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}
						}else if(showColumns[i].indexOf("totaltime")>-1){
							var numS=parseFloat(alarmObj[showColumns[i]]);
							var m=Math.floor(numS/60);
							var s=Math.floor(numS%60);
							var showStr="";
							if(m>0){
								if(tabName=="疲劳驾驶明细"||tabName=="疲劳驾驶报警"){
									if(m>60){
										showStr=Math.floor(m/60)+"时"+Math.floor(m%60)+"分";
									}else{
										showStr=m+"分";
									}
									
								}else{
									showStr=m+"分"+s+"秒";
								}
								
							}else{
								showStr=s+"秒";
							}
							tr+="<td>"+showStr+"</td>";
						}else if(showColumns[i].indexOf("totalmileage")>-1){
							tr+="<td>"+(parseFloat(alarmObj[showColumns[i]])).toFixed(1)+"</td>";
						}else if(showColumns[i].indexOf("over_speed_mileage")>-1){
							tr+="<td>"+(parseFloat(alarmObj[showColumns[i]])).toFixed(1)+"</td>";
						}else{
							tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
						}
					}
					tr+="</tr>";
				}
				$("#alarmDetailTable").append(tr);
			}else{
				$("#alarmDetailTable").append("<tr align=\"center\"><td colspan=\""+showColumns.length+"\" align=\"center\">无数据显示</td></tr>");
				$('.trackTabCont').find('.list').hide().eq(0).show();
			}
		},
		showImage:function(imageUrl){
			$("#hisImage").attr('src',imageUrl); 
			$('#detailPop').modal('show');
		}
}



var alarmDetail = {
		nightTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>行驶时长</th><th>行驶里程</th>",
		speedTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>累计时间</th><th>累计里程</th><th>最高速度</th><th>最低速度</th><th>平均速度</th></tr>",
		roadLevelSpeedTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>道路类型名称</th><th>超速时长</th><th>限速</th><th>开始时间</th><th>结束时间</th><th>开始地点</th><th>结束地点</th><th>超速里程</th><th>最高速度</th><th>最低速度</th><th>平均速度</th></tr>",
		tiredTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>查看轨迹</th><th>开始时间</th><th>开始疲劳时间</th><th>结束时间</th><th>累计时间</th><th>累计里程</th><th>开始地点</th><th>结束地点</th></tr>",
		picTbHead:"<tr id=\"objTitle\" style=\"background-color: #DDDDDD;\"><th>拍照时间</th><th>行驶速度</th><th>里程</th><th>查看图片</th><th>拍照地点</th></tr>",
		/**
		 * 超速详情
		 * 
		 * @param count
		 * @param vid
		 * @param star
		 * @param end
		 */
		querySpeed:function(count,vid,star,end,type){
			var showSpeedAlarm = function(alarmList){
				exportAlarmImageTitles="开始时间,结束时间,累计时间,累计里程,最高速度,最低速度,平均速度";
				exportAlarmColumns=["startdatetime","enddatetime",
									 "totaltime","totalmileage","maxspeed","minspeed","averagespeed"];
				if(type==1){
					alarmDetail.showAlarm(
							"超速报警明细",
							alarmDetail.speedTbHead,
							alarmList,
							["showThreeDetailTrackInfo","startdatetime","enddatetime","intPosition","outPosition",
							 "totaltime","totalmileage","maxspeed","minspeed","averagespeed"]
					);
				}else{
					alarmDaily.showAlarm(
							"超速报警",
							alarmDetail.speedTbHead,
							alarmList,
							["showDetailTrackInfo","startdatetime","enddatetime","intPosition","outPosition",
							 "totaltime","totalmileage","maxspeed","minspeed","averagespeed"]
					);
				}
			};
			reportbase.queryAlarmDetail(
					"report/alarm/detail/overSpeedOps.jhtml",{
					"vehicleId":vid,
					"starDateTime":star,
					"endDateTime":end
					},
					showSpeedAlarm
			);
		},
		/**
		 * 道路类型超速报警
		 * @param count
		 * @param vid
		 * @param star
		 * @param end
		 */
		queryRoadLevelSpeed:function(count,vid,star,end,type){
			var showRoadLevelOverSpeedAlarm = function(alarmList){	
				exportAlarmImageTitles="道路类型名称,超速时长,限速,开始时间,结束时间,超速里程,最高速度,最低速度,平均速度";
				exportAlarmColumns=["roadLevelName","totaltime","limitspeed","startdatetime","enddatetime",
							        "over_speed_mileage",
							        "maxspeed","minspeed","avgspeed"];
				if(1==type){
					alarmDetail.showAlarm(
							"道路类型超速明细",
							alarmDetail.roadLevelSpeedTbHead,alarmList,
							["showThreeDetailTrackInfo","roadLevelName","totaltime","limitspeed","startdatetime","enddatetime",
					        "intPosition","outPosition","over_speed_mileage",
					        "maxspeed","minspeed","avgspeed"]
					);
				}else{
					alarmDaily.showAlarm(
							"道路类型超速报警",
							alarmDetail.roadLevelSpeedTbHead,alarmList,
							["showDetailTrackInfo","roadLevelName","totaltime","limitspeed","startdatetime","enddatetime",
					        "intPosition","outPosition","over_speed_mileage",
					        "maxspeed","minspeed","avgspeed"]
					);
				}
			};
			reportbase.queryAlarmDetail(
					"report/alarm/detail/roadLevelSpeedOps.jhtml",{
					"vehicleId":vid,
					"starDateTime":star,
					"endDateTime":end
					},
					showRoadLevelOverSpeedAlarm
			);
		},
		/**
		 * 夜间行车报警
		 * 
		 * @param count
		 * @param vid
		 * @param star
		 * @param end
		 */
		queryNightAlarm:function(count,vid,star,end,type){
			var nightAlarm = function(alarmList){	
				exportAlarmImageTitles="开始时间,结束时间,行驶里程,行驶时长";
				exportAlarmColumns=["startdatetime","enddatetime","totalmileage","totaltime"];
				if(1==type){
					alarmDetail.showAlarm(
							"夜间行车明细",
							alarmDetail.nightTbHead,
							alarmList,
							["showThreeDetailTrackInfo","startdatetime","enddatetime","intPosition","outPosition","totaltime","totalmileage"]
					);
				}else{
					alarmDaily.showAlarm(
							"夜间行车报警",
							alarmDetail.nightTbHead,
							alarmList,
							["showDetailTrackInfo","startdatetime","enddatetime","intPosition","outPosition","totaltime","totalmileage"]
					);
				}
			};
			reportbase.queryAlarmDetail(
					"report/alarm/detail/nightDrivingOps.jhtml",{
					"vehicleId":vid,
					"starDateTime":star,
					"endDateTime":end
					},
					nightAlarm
			);
		},
		/**
		 * 疲劳驾驶报警
		 * 
		 * @param count
		 * @param vid
		 * @param star
		 * @param end
		 */
		queryTiredAlarm:function(count,vid,star,end,type){
			var showSpeedAlarm = function(alarmList){
				exportAlarmImageTitles="开始时间,开始疲劳时间,结束时间,累计时间,累计里程";
				exportAlarmColumns=["startdatetime","starttiredtime","enddatetime","totaltime","totalmileage"];
				if(1==type){
					alarmDetail.showAlarm(
							"疲劳驾驶明细",
							alarmDetail.tiredTbHead,
							alarmList,
							["showThreeDetailTrackInfo","startdatetime","starttiredtime","enddatetime","totaltime","totalmileage","startposition","endposition"]
					);
				}else{
					alarmDaily.showAlarm(
							"疲劳驾驶报警",
							alarmDetail.tiredTbHead,
							alarmList,
							["showDetailTrackInfo","startdatetime","starttiredtime","enddatetime","totaltime","totalmileage","startposition","endposition"]
					);
				}
			};
			reportbase.queryAlarmDetail(
					"report/alarm/detail/tiredAlarmOps.jhtml",{
					"vehicleId":vid,
					"starDateTime":star,
					"endDateTime":end
					},
					showSpeedAlarm
			);
		},
		queryHisImage:function(count,vid,star,end,type){
			var showHisImage=function(alarmList){
				draw.drawImage(alarmList,mapTool.map);
				exportAlarmImageTitles="拍照时间,行驶速度,里程";
				exportAlarmColumns=["gpsTimeStr","gpsSpeed","gpsMileage"];
				if(1==type){
					alarmDetail.showAlarm(
							"历史图片明细",
							alarmDetail.picTbHead,
							alarmList,
							["gpsTimeStr","gpsSpeed","gpsMileage","imgUrl","picPosition"]
					);
				}else{
					alarmDaily.showAlarm(
							"历史图片",
							alarmDetail.picTbHead,
							alarmList,
							["gpsTimeStr","gpsSpeed","gpsMileage","imgUrl","picPosition"]
					);
				}
			}
			reportbase.queryAlarmDetail(
					"report/historyPic/queryPicListByVehicleIdOps.jhtml",{
					"vehicleId":vid,
					"startTime":star,
					"endTime":end
					},
//					"vehicleId":29011,
//					"startTime":"2017-07-01 00:00:00",
//					"endTime":"2017-07-02 23:59:59"
					showHisImage
			);
		},
		// 显示报警
		showAlarm:function(tabName,tbHead,alarmList,showColumns){
			tabUtils.show(["li_tab_2","alarmDetailList2"],["trackList","alarmTrackList","li_tab_3"],2,tabName);
			$("#alarmDetailTable2").html("");
			$("#alarmDetailTable2").html(tbHead);
			if(null!=alarmList && alarmList!=""){
				var columnsSize = showColumns.length;
				var tr ="";
				exportAlarmListInfo=alarmList;
				for(var j=0;j<alarmList.length;j++){
					var alarmObj = alarmList[j];
					if(i%2==0 && tabName!="历史图片"){//onclick='trackQuery.showAlarmTrack("+ JSON.stringify(alarmObj)+",0)'
						tr+="<tr style=\"background-color: #F8F8FF;\"  >";
					}else if(tabName!="历史图片"){// onclick='trackQuery.showAlarmTrack("+ JSON.stringify(alarmObj)+",0)'
						tr+="<tr >";
					}else{
						tr+="<tr onclick='draw.setCenter("+ alarmObj.gdLng+","+alarmObj.gdLat+")'>";
					}	
					for(var i=0;i<columnsSize;i++){
						if(showColumns[i].indexOf("startposition")>-1 || showColumns[i].indexOf("intPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.startlon+"','"+alarmObj.startlat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}
						}else if(showColumns[i].indexOf("endposition")>-1  || showColumns[i].indexOf("outPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.endlon+"','"+alarmObj.endlat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}							 
						}else if(showColumns[i].indexOf("picPosition")>-1){
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\"mapUtils.getAddress(this,'"+alarmObj.gdLng+"','"+alarmObj.gdLat+"');\">查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}							 
						}else if (showColumns[i].indexOf("imgUrl")>-1){
							var imageUrl = alarmObj[showColumns[i]];
							tr+="<td><a style='cursor:pointer;'  onclick=\"alarmDaily.showImage('"+imageUrl+"')\">查看</a></td>";
						}else if(showColumns[i].indexOf("showDetailTrackInfo")>-1){
							
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\'trackQuery.showAlarmTrack("+JSON.stringify(alarmObj)+",0);\'>查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}
						}else if(showColumns[i].indexOf("showThreeDetailTrackInfo")>-1){
							
							var vName = showColumns[i];
							var vValue = alarmObj[showColumns[i]];
							if(vValue==undefined ||  vValue==""){
								tr+="<td><a style='cursor:pointer;' href=\"#\"  onclick=\'trackQuery.showAlarmTrack("+JSON.stringify(alarmObj)+",1);\'>查看</a></td>";
							}else{
								tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
							}
						}else if(showColumns[i].indexOf("totaltime")>-1){
							var numS=parseFloat(alarmObj[showColumns[i]]);
							var m=Math.floor(numS/60);
							var s=Math.floor(numS%60);
							var showStr="";
							if(m>0){
								if(tabName=="疲劳驾驶明细"||tabName=="疲劳驾驶报警"){
									if(m>60){
										showStr=Math.floor(m/60)+"时"+Math.floor(m%60)+"分";
									}else{
										showStr=m+"分";
									}
									
								}else{
									showStr=m+"分"+s+"秒";
								}
								
							}else{
								showStr=s+"秒";
							}
							tr+="<td>"+showStr+"</td>";
						}else if(showColumns[i].indexOf("totalmileage")>-1){
							tr+="<td>"+(parseFloat(alarmObj[showColumns[i]])).toFixed(1)+"</td>";
						}else if(showColumns[i].indexOf("over_speed_mileage")>-1){
							tr+="<td>"+(parseFloat(alarmObj[showColumns[i]])).toFixed(1)+"</td>";
						}else{
							tr+="<td>"+alarmObj[showColumns[i]]+"</td>";
						}
					}
					tr+="</tr>";
				}
				$("#alarmDetailTable2").append(tr);
			}else{
				$("#alarmDetailTable2").append("<tr align=\"center\"><td colspan=\""+showColumns.length+"\" align=\"center\">无数据显示</td></tr>");
			}
		}
}